<?php

namespace Emergine\Interfaces
{
/**
   * emergine.CMI -- Common Model Interface (CMI)
   * @version: 1.0
   * @author: Hleb Piatrou <h.piatrou@softteco.com>
   * @link: http://code.google.com/p/emergine/
   * @copyright: Copyright 2011-2012 Hleb Piatrou
   * @license: MIT License http://www.opensource.org/licenses/mit-license.php
   * @interface: Common Model Interface (CMI)
   */
    interface Models
	{
		/**
		 * ArrayContent() function
		 *  
		 * Method, which returns the content of models as an ArrayObject
		 * Usage:
		 * <code>
		 * $array_content = Models::ArrayContent();
		 * print_r($array_content);
		 * </code>
		 * @access: public
		 * @param: none
		 * @return: array
		 */
		public function ArrayContent();
		/**
		 * ObjectContent() function
		 *  
		 * Method, which returns the content of models as an StdObject
		 * Usage:
		 * <code>
		 * $object_content = Models::ObjectContent();
		 * print_r($object_content);
		 * </code>
		 * @access: public
		 * @param: none
		 * @return: object
		 */		
		public function ObjectContent();
		/**
		 * TableName() function
		 *  
		 * Method, which returns the name of table by the index number
		 * Usage:
		 * <code>
		 * $table = Models::TableName(0);
		 * print_r($table);
		 * </code>
		 * @access: public
		 * @param: int $index - The index number of models array
		 * @return: string
		 */	
		public function TableName($index);
		/**
		 * TableContent() function
		 *  
		 * Method, which returns the content of table by the index number
		 * Usage:
		 * <code>
		 * $table = Models::TableName(0);
		 * print_r($table);
		 * </code>
		 * @access: public
		 * @param: int $index - The index number of models array
		 * @return: array
		 */		
		public function TableContent($index);
		/**
		 * TableOptions() function
		 *  
		 * Method, which returns the value of table options by option name,
		 * for example primary/foreign keys, table type etc.  
		 * Usage:
		 * <code>
		 * $contene = Models::TableContent(0);
		 * print_r($content);
		 * </code>
		 * @access: public
		 * @param: string $option_name - the name of table option
		 * @return: string
		 */
		public function TableOptions($option_name);
		/**
		 * Field() function
		 *  
		 * Method, which returns the name of field by the table index 
		 * and index of field
		 * Usage:
		 * <code>
		 * $field = Models::Field(0,1); // returns the name of 2nd field of 1st table
		 * print_r($field);
		 * </code>
		 * @access: public
		 * @param: int $table_undex - the number of table, int $index - the number of field
		 * @return: string
		 */	
		public function Field($table_index, $index);
		/**
		 * FieldType() function
		 *  
		 * Method, which returns the type of field by the table index 
		 * and the index of field
		 * Usage:
		 * <code>
		 * $field_type = Models::FieldType(0,1); // returns the type of 2nd field of 1st table
		 * print_r($field_type);
		 * </code>
		 * @access: public
		 * @param: int $table_undex - the number of table, int $index - the number of field
		 * @return: string
		 */	
		public function FieldType($table_index, $index);
		/**
		 * MaxValue() function
		 *  
		 * Method, which returns the maximum value of characters in the 
		 * field by the table index and the index of field
		 * Usage:
		 * <code>
		 * $field_type = Models::MaxValue(0,1); // returns the type of 2nd field of 1st table
		 * print_r($field_type);
		 * </code>
		 * @access: public
		 * @param: int $table_undex - the number of table, int $index - the number of field
		 * @return: int
		 */
		public function MaxValue($table_index, $index);
				/**
		 * DBServer() function
		 *  
		 * Method, which calls the function of building queries on your
		 * selected database server
		 * Usage:
		 * <code>
		 * Models::DBServer('CreateTable') // Create database table from models
		 * </code>
		 * @access: public
		 * @param: string $query - SQL construction, which you want to generate
		 * @ from your models. Supported queries: AlterTable, CreateTable
		 * @return: none
		 */
		public function DBServer($query, $param);
		/**
		 * SuncDB() function
		 *  
		 * Method, which syncronize your models with database
		 * Usage:
		 * <code>
		 * Models::SyncDB();
		 * </code>
		 * @access: public
		 * @param: none
		 * @return: none
		 */		
		public function SyncDB();
		/**
		 * Save() function
		 *  
		 * Method, which saves inserted by user objects in database
		 * Usage:
		 * <code>
		 * $person = new Models("Users");
		 * $person->id = 1;
		 * $person->name = "Hleb Piatrou";
		 * $person->age = 20;
		 * Models::Save($person);
		 * </code>
		 * @access: public
		 * @param: none
		 * @return: none
		 */		
	    public function Save($object);
	}
	
	interface MySQL
	{
		/**
		 * CreateTable() function
		 *  
		 * Method, which generates the CREATE TABLE construction
		 * using MySQL database server and write it into the
		 * mysql.models.sql file in /cache directoty 
		 * Usage:
		 * <code>
		 * MySQL::CreateTable();
		 * </code>
		 * @access: public
		 * @param: none
		 * @return: none
		 */	
		public function CreateTable();
		/**
		 * AlterTable() function
		 *  
		 * Method, which generates the ALTER TABLE construction
		 * using MySQL database server and write it into the
		 * mysql.models.sql file in /cache directoty 
		 * Usage:
		 * <code>
		 * MySQL::AlterTable();
		 * </code>
		 * @access: public
		 * @param: none
		 * @return: none
		 */			
		public function AlterTable();
		/**
		 * FieldType() function
		 *  
		 * Method, which returns the type of field by number of table
		 * and number of field  
		 * Usage:
		 * <code>
		 * $type = MySQL::FieldType();
		 * print_r($type);
		 * </code>
		 * @access: public
		 * @param: int $table_undex - the number of table, int $index - the number of field
		 * @return: string
		 */	
		 public function FieldType($table_index, $index);
		/**
		 * Insert() function
		 *  
		 * Method, which insert inputed values into the database 
		 * Usage:
		 * <code>
		 * MySQL::Insert($param);
		 * </code>
		 * @access: public
		 * @param: int $param - an object of inserted keys and values
		 * @return: none
		 */	
		 public function Insert($param);
	}
}
?>
